<template>
  <div>
    <van-goods-action>
      <van-goods-action-icon icon="chat-o" text="客服" />
      <van-goods-action-icon
        icon="cart-o"
        text="购物车"
        :badge="goodsCount"
        @click="gotoCart"
      />
      <van-goods-action-icon
        :icon="isCollected ? 'star' : 'star-o'"
        :text="isCollected ? '已收藏' : '未收藏'"
        :color="isCollected ? '#ff5000' : '#666'"
        @click="isCollected = !isCollected"
      />
      <van-goods-action-button
        color="#be99ff"
        type="warning"
        text="加入购物车"
        @click="onAddCartClicked"
      />
      <van-goods-action-button
        color="#7232dd"
        type="danger"
        text="立即购买"
        @click="onBuyClicked"
      />
    </van-goods-action>
  </div>
</template>

<script>
export default {
  props: ["goodsCount"],
  data() {
    return {
      isCollected: false,
    };
  },
  methods: {
    onBuyClicked() {
      this.$toast("该功能未开放");
    },
    onAddCartClicked() {
      this.$emit("gotoCart");
    },
    gotoCart() {
      this.$router.push("/cart");
    },
  },
};
</script>

<style lang="less" scoped>
.van-goods-action {
  z-index: 99999;
}
</style>